<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>机构端</title>
        <script src="/Public/static/jquery-2.0.3.min.js"></script>
        <script src="/Public/static/layer/layer.js"></script>
        <link rel="stylesheet" href="__PUBLIC__/Home/css/reset.css">
        <link rel="stylesheet" href="__PUBLIC__/Home/css/style.css">
        <link rel="stylesheet" href="__PUBLIC__/Home/css/page.css" />
	</head>

	<body class="agency_box contentBox pos_rel dpflxr">
		<!-- 1.顶部logo导航 -->
		<include file="head" />

		<!-- 2.垂直导航 -->
		<div class="navColumn">
			<a href="{:U('Mechanism/floor_index')}" <if condition="$cur eq 楼盘管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if> data-type='1'>
				<div class="lineColumn pos_abs"></div>
				<label for="">楼盘管理</label>
				<div class="rightArrow">
				</div>
			</a>
			<a href="{:U('Mechanism/house_type')}"  <if condition="$cur eq 户型管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if> data-type='2'>
				<div class="lineColumn pos_abs"></div>
				<label for="">户型管理</label>
				<div class="rightArrow">
				</div>
			</a>
			<a href="{:U('Mechanism/build_manage')}" <if condition="$cur eq 楼栋管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if>  data-type='3'>
				<div class="lineColumn pos_abs"></div>
				<label for="">楼栋管理</label>
				<div class="rightArrow">
				</div>
			</a>
			<a href="{:U('Mechanism/souse_res')}" <if condition="$cur eq 房源管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if>  data-type='4'>
				<div class="lineColumn pos_abs"></div>
				<label for="">房源管理</label>
				<div class="rightArrow">
				</div>
			</a>
			
		</div>



		<!-- 二 3.1 楼盘管理  -->
		<div class="contentArea tabPage actived">
			<!-- 3.1.2 新增楼栋 -->
			<div class="addProject">
				<div class="caTitleBox dpflxr">
					<label for="" class="caTitle">新增楼栋</label>
				</div>
				
				
				<!-- 3.1.2.1 基本信息-->
				<div class="switchPage tabPageF actived card dpflxr">
					
					<div class="contentItem  dpflxr ">
						<label for="" class="title">楼栋名称：</label>
						<div class="pos_rel">
							<input type="text" class="inputBox" name="building_name" value="{$info['building_name']}" placeholder="请输入楼栋名称" style="padding-right: 56px;"
								placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>
							<label class="pos_abs unit">0/10</label>
						</div>
						
					</div>
					<div class="contentItem  dpflxr">
						<label for="" class="title">所属楼盘：</label>
						
						<select name="floor_id" id="fl" class="selectBox" onchange="ff()">
							<volist name="floor_list" id="item">
								<option value="{$item['id']}" <if condition="$info['floor_id'] eq $item['id']">selected</if>>{$item['name']}</option>
							</volist>
						</select>
					</div>
					
					<div class="contentItem  dpflxr">
						<label for="" class="title">销售状态：</label>
						
						<select name="status" id="st" class="selectBox">
							<option value="1" <if condition="$info['status'] eq 1">selected</if>>待售</option>
							<option value="2" <if condition="$info['status'] eq 2">selected</if>>在售</option>
							<option value="3" <if condition="$info['status'] eq 3">selected</if>>售罄</option>
						</select>
					</div>
				
					<div class="contentItem  dpflxr ">
						<label for="" class="title">单元数：</label>
						<div class="pos_rel">
							<input type="text" class="inputBox" name="unit_number" value="{$info['unit_number']}" placeholder="请输入单元数" style="padding-right: 56px;"
								placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>
							<label class="pos_abs unit">个</label>
						</div>
						
					</div>
					<div class="contentItem  dpflxr">
						<label for="" class="title">电梯数：</label>
						
<!-- 						<select name="" id="" class="selectBox">
							<option value="">1梯4户</option>
							<option value="">1梯4户</option>
						</select> -->

							<div class="pos_rel">
							<input type="text" class="inputBox" name="elevator" value="{$info['elevator']}" placeholder="几梯几户" style="padding-right: 56px;"
								placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>

						</div>
					</div>
					<div class="contentItem  dpflxr">
						<label for="" class="title">建筑类型：</label>
													<div class="pos_rel">
							<input type="text" class="inputBox" name="type" value="{$info['type']}" placeholder="高层低层" style="padding-right: 56px;"
								placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>

						</div>
<!-- 						<select name="" id="" class="selectBox">
							<option value="">高层</option>
							<option value="">高层</option>
						</select> -->
					</div>
					<div class="contentItem  dpflxr ">
						<label for="" class="title">楼梯数：</label>
						<div class="pos_rel">
							<input type="text" class="inputBox" name="layer" value="{$info['layer']}" placeholder="请输入多少层" style="padding-right: 56px;"
								placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>
							<label class="pos_abs unit">层</label>
						</div>
						
					</div>
					<div class="contentItem  dpflxr ">
						<label for="" class="title">户数：</label>
						<div class="pos_rel">
							<input type="text" class="inputBox" name="households" value="{$info['households']}" placeholder="请输入单元每层户数" style="padding-right: 56px;"
								placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>
							<label class="pos_abs unit">户</label>
						</div>
						
					</div>
					<div class="contentItem  dpflxr ">
						<label for="" class="title">在售房源：</label>
						<div class="pos_rel">
							<input type="text" class="inputBox" name="house_sale" value="{$info['house_sale']}" placeholder="请输入在售房源数量" style="padding-right: 56px;"
								placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>
							<label class="pos_abs unit">套</label>
						</div>
						
					</div>
					<div class="contentItem type  dpflxrw ">
						<label for="" class="title">户型：</label>
						<div class="dpflxrc selectType">
							<div id="selectTypeBtn" class="selectBtn">选择户型</div>
							<div class="optionBox dpflxr">
								<volist name="list" id="item">
									<div class="optionItem dpflxrjb">
										<label>{$item['name']}  |  {$item['house_config']}  |  {$item['house_area']}㎡  |  {$item['status_name']}</label>
										<input type="hidden" name="bbid" data-id="{$item['id']}">
										<div class="icon">
											<img src="__PUBLIC__/Home/images/shanchu.png" >
										</div>
									</div>
								</volist>
							</div>
						</div>
						
					</div>
					
					
					
					<input type="hidden" name="id" value="{$info['id']}">
					<div class="ciBtnWrapper">
						<div class="ciBtn"><label>确认</label></div>
					</div>
					
				
				</div>
				
				


			</div>
		</div>
			
		<!-- 4.弹窗部分 -->
		<!-- [shadowLayer] -->
		<div id="shadowLayer" class="shadowLayer pos_abs dpflx">
			
			<!-- 弹窗1 选择户型 -->
			<div id="selectType" class="pupupWindows">
				<div class="pwTitle dpflxr">
					<label>选择户型</label>
					<div id="closeBtn" class="closeBtn">
						<img src="__PUBLIC__/Home/images/icon_close1.png" >
					</div>
				</div>
				<div class="pwContent">
<!-- 					<div class="searchBox dpflxrjb">
							<input placeholder="输入户型名称" />
							<label class="searchBtn">搜索</label>
					</div>	 -->
					<div class="typeList dpflxrjb">
						
						<volist name="type_list" id="item">
							<div class="optionItem dpflxrjb actived">
								<label>{$item['name']}  |  {$item['house_config']}  |  {$item['house_area']}㎡  |  {$item['status_name']}</label>
								<input type="checkbox" name="type_id" value="{$item.id}">
							</div>
						</volist>
						
						<div class="dpflxrw" style="justify-content: flex-end;">
							<div class="tlBtn">确认选择</div>
						</div>
						
					</div>
				</div>
				
			</div>
		
			
		</div>
		<!-- [/shadowLayer] -->
		
		<script src="__PUBLIC__/Home/js/popupWindows.js" type="text/javascript" charset="utf-8"></script>
	</body>
</html>
<script type="text/javascript">
	function ff(){
		var floor_id=$("#fl").val();
    	$.ajax({
            url:"{:U('Mechanism/house_show')}",
            data:{floor_id:floor_id},
            dataType:'json',
            type:'post',
            success:function(data){
            	var hh='';
                $.each(data.data,function(k,v){
				hh+='<div class="optionItem dpflxrjb actived">';
				hh+='<label>'+v.name+'  |  '+v.house_config+'  |  '+v.house_area+'㎡  |  '+v.status_name+'</label>';
				hh+='<input type="checkbox" name="type_id" value="'+v.id+'">';
				hh+='</div>';
                });
                hh+='<div class="dpflxrw" style="justify-content: flex-end;">';
				hh+='<div class="tlBtn">确认选择</div>';
				hh+='</div>';
            	$('.typeList').html(hh);

            }
        })
	}

	//确认选择
	$("body").on('click','.tlBtn',function(){
    	var chk_value =[];
		$("input[type='checkbox']:checked").each(function(){
		    chk_value.push($(this).val());
	    });
	    $.ajax({
            url:"{:U('Mechanism/choice_type')}",
            data:{chk_value:chk_value},
            dataType:'json',
            type:'post',
	        success: function (data) {
	        	// console.log(data);return false;
	        	var hh='';
                $.each(data.data,function(k,v){
				hh+='<div class="optionItem dpflxrjb">';
				hh+='<label>'+v.name+'  |  '+v.house_config+'  |  '+v.house_area+'㎡  |  '+v.status_name+'</label>';
				hh+='<input name="bbid" type="hidden" data-id="'+v.id+'">';
				hh+='<div class="icon">';
				hh+='<img src="__PUBLIC__/Home/images/shanchu.png" >';
				hh+='</div>';
				hh+='</div>';
                });
            	$('.optionBox').html(hh);
            	$("#shadowLayer").hide();
	        },
	    })
	})	
	//删除户型
	$("body").on('click','.icon',function(){
		$(this).parent().remove();
	})

	//保存
	$("body").on('click','.ciBtn',function(){
		var id=$("input[name='id']").val();
		var building_name=$("input[name='building_name']").val();
		var floor_id=$("#fl").val();
		var status=$("#st").val();
		var unit_number=$("input[name='unit_number']").val();
		var elevator=$("input[name='elevator']").val();
		var type=$("input[name='type']").val();
		var layer=$("input[name='layer']").val();
		var households=$("input[name='households']").val();
		var house_sale=$("input[name='house_sale']").val();
		var ll = $("input[name='bbid']");
		var chk=[];
		for (var ii = 0; ii < ll.length; ii++) {
			var jj = ll.eq(ii).attr('data-id');
			chk.push(jj);
		}
		// console.log(building_name);
		// console.log(floor_id);
		// console.log(status);
		// console.log(unit_number);
		// console.log(elevator);
		// console.log(type);
		// console.log(households);
		// console.log(house_sale);
		$.ajax({
            url:"{:U('Mechanism/save_type')}",
            data:{id:id,building_name:building_name,floor_id:floor_id,status:status,unit_number:unit_number,elevator:elevator,type:type,layer:layer,households:households,house_sale:house_sale,chk:chk},
            dataType:'json',
            type:'post',
	        success: function (data) {
	        	// console.log(data);return false;
					if (data.result == 1) {
						alert(data.msg);
						var url = "/index.php?s=/Home/Mechanism/build_manage.html";
						location.href = url;
					} else {
						alert(data.msg);
						var url = "/index.php?s=/Home/Mechanism/build_manage.html";
						location.href = url;
					}
	        },
	    })
	})
</script>